package is.model.bean;

import is.NullUtil;
import is.interfaces.Bean;
import is.interfaces.HierarchyBean;
import java.sql.ResultSet;
import java.sql.SQLException;

/**
 *
 * @author aspr0
 */
public class Region extends AbstractHierarchyBean implements Bean, HierarchyBean, Cloneable
{
    private String name;

    public Region()
    {
        tableName = "region";
        fields = new String[]
        {
            "parentId", "name"
        };
    }

    @Override
    public void processResultSet(ResultSet resultSet) throws SQLException
    {
        id = resultSet.getInt(KEY_FIELD);
        parentId = resultSet.getInt(fields[0]);
        name = resultSet.getString(fields[1]);
    }

    public String getName()
    {
        return name;
    }

    public void setName(String name)
    {
        this.name = name;
    }

    @Override
    public String[] getValues()
    {
        return new String[]
                {
                    NullUtil.toString(parentId), NullUtil.toString(name),
                };
    }
}
